Skip to content

feat(run): run current files and individual functions - #51

Merged
xiaoyumuxi merged 1 commit into
mainfrom
feat/current-file-and-function-runs
Nov 29, 2026
Merged

xiaoyumuxi merged 1 commit into
mainfrom
feat/current-file-and-function-runs

Conversation

@xiaoyumuxi

Copy link
Copy Markdown
Contributor

Closes #50

关联 Issue / Linked issue

Closes #50

PR 类型 / Type

  • feat:新功能或用户可见的改进
  • fix:缺陷修复
  • docs:文档、Agent Note、Skill 等规则文件
  • release:稳定版发布准备

改动说明 / What changes

背景 / Why

语言插件原有运行入口集中在构建窗口,编辑器打开当前文件时不能直接识别可执行入口;测试模块也不能从函数或方法声明旁边精确运行单个测试。这使模块依赖测试和快速回归需要手写命令或切换运行配置。

改动 / Changes

  • Java 后端通过 JDT 语义识别当前文件中的 main、JUnit 测试类和方法,提供 Run/Debug gutter 入口;混合 main/test 类的类级动作优先测试动作,单方法使用精确 JUnit 标识符。
  • 复用现有 editor.actions 与 run.start,点击前重新读取文档、版本、路径和声明;保存成功后才启动,rerun 会再次验证当前声明。
  • 统一 Windows/macOS 工作区相对路径为 /,拒绝空路径、绝对路径、盘符、反斜杠、控制字符、. 和 ..;执行器路径和工具链来源按宿主选择解析。
  • 增加后端单元、真实工具 action 回归、声明移除/陈旧版本/保存失败/rerun 安全拒绝覆盖,以及明暗主题、中英文、before/after/hover 截图。
  • 更新 README 与 docs/feature-matrix.md,固定 Rust 工具链为 1.100.0,并保留 SDK revision 65cf82343c5e315aae2e335b2e8f0217b703e89a。

不在本 PR 范围内 / Out of scope

  • PHP、Lua 插件不在本次四仓改动范围内。
  • 不修改宿主 Lithe-IDEA 或 Lithe-core-rust,也不新增 Core 契约;使用已有声明式动作和运行 API。
  • 当前机器是原生 Windows 11 Pro x64;macOS 原生窗口、其他架构及完整 CI 由 CI/实机继续验收,矩阵保持 pending。

类型专属:feat

多平台对齐

  • 两端都具备:实现使用平台无关的声明与相对路径协议,Windows 11 x64 已完成真实工具回归;macOS 原生窗口验证仍按矩阵标为 pending。
  • 只实现了 macOS
  • 只实现了 Windows
  • 刻意只属于某个平台

范围检查 / Scope checks

功能矩阵 / Feature matrix

  • [N/A] 未修改宿主 shared/platform-feature-matrix/features/<id>.json;这是插件能力,已更新本仓库 docs/feature-matrix.md 并如实保留 macOS/其他架构 pending。
  • [N/A] 宿主矩阵验证脚本不适用于插件仓库;插件侧脚本和真实 action 已运行。
  • 未提交 .artifacts/ 生成的矩阵视图或临时运行目录。

插件归属 / Plugin ownership

  • 代码、测试、功能矩阵、翻译和截图均在本插件仓库;宿主/Core 无具体插件依赖。
  • 新增插件测试在本仓库维护,使用本仓合成 fixture、固定工具和宿主契约;Viva 截图使用固定宿主检出,不将具体插件测试写入宿主仓库。
  • 没有为具体插件能力新增宿主功能矩阵条目,插件构建与资源说明留在本仓库。
  • 插件文案未写入宿主 shared/i18n/,插件清单和运行消息由插件自己翻译。
  • [N/A] 未修改通用扩展点;不需要在其他插件仓库运行通用扩展点回归。

UI 验证 / UI evidence

  • 已运行 scripts/run/visual.mjs 生成并检查 Viva 无头截图;覆盖 Windows x64、before/after/hover、light/dark、en/zh-Hans,逻辑窗口 1440×900(输出 2880×1800)。
  • 固定截图宿主 4191c1553486247026c767ccd52b5cd9e8f38115、Core d426f018065c950754140295e857bc71b870139f。
  • 已在本 PR 嵌入代表性 before/after/hover 截图:

Java before

Java after

Java test hover

  • macOS 原生窗口和其他架构验收:待 CI/实机验证,未将无头或组件测试记作原生窗口通过。

统一日志系统 / Structured logging

  • 运行请求沿用 SDK/宿主统一日志系统;插件没有新增 stderr、print、私有事件 ID 或直接日志旁路。
  • 一个 action 只有一个终态;高频声明收集不逐项输出成功日志。
  • 日志和错误不记录源码、环境变量值、命令输出或凭据;路径和错误使用既有结构化字段。
  • [N/A] 未新增旧日志生成器;固定 Core 的 SDK 日志接线保持不变。

界面文案 / i18n

  • 插件清单、运行动作标题和后端提示由插件自己的中英翻译提供,未写入宿主共享词条。
  • node scripts/i18n/verify-app-language-localization.mjs 已通过。
  • node scripts/i18n/generate-i18n.mjs --check:宿主基线已有 desktop/internal/i18n/shared.generated.go 漂移;本 PR 未修改宿主来掩盖该既有问题。

逻辑归属 / Logic placement

  • 当前文件/函数解析、声明校验、精确过滤器和相对路径安全逻辑在插件 Rust 后端;宿主只负责声明式动作和运行窗口。
  • [N/A] 未修改宿主平台层共享逻辑,不存在需要迁入 Core 的新平台分支。
  • Go/Python/Rust/Java 的工具链专属知识留在各自插件,上游 rust-analyzer/JDT/tree-sitter 只在插件侧使用。

性能与内存 / Performance and memory

  • 解析和子进程只在打开动作或真实运行时触发;没有新增空闲轮询,临时进程和缓存按测试生命周期清理。
  • 主线程没有新增文件遍历或进程启动;动作请求传递受校验的增量声明。
  • [N/A] 未改变宿主启动、编辑器输入、滚动或长输出路径;安装包体积基线未作为宿主性能门禁。

设置 / Settings

  • [N/A] 没有新增或移动设置、设置页或对话框选项。

插件契约 / Plugin contract

  • [N/A] 没有修改 Core 契约、能力版本、插件 RPC、宿主方法或通知;沿用现有 editor.actions / run.start。
  • 后端 SDK revision 固定为 65cf82343c5e315aae2e335b2e8f0217b703e89a;本 PR 不需要升级 Core pin 或新增 API 计划编号。
  • [N/A] 未修改插件后端协议,不需要在 Core 仓库运行 SDK e2e。
原计划编号 方法 用途
— — 未新增或修改宿主方法

发行包与资源 / Bundle and resources

  • 运行时不向已安装 app bundle、Windows 安装目录或插件只读资源写入;临时项目、工具状态和运行输出使用测试临时目录,已清理本轮新增进程与临时产物。
  • [N/A] 宿主 verify-runtime-bundle-immutability.sh 只属于 Lithe-IDEA 宿主仓;本 PR 没有宿主 bundle 改动。

无用代码与重构 / Dead code and refactoring

  • 本次实现未留下新增无用代码,相关旧入口和文档限制已同步更新。
  • 本次之前存在的可重构之处:未建单:refactor 标签不存在。

验证 / Verification

命令或操作 平台 结果
git diff --check、node --check scripts/run/*.mjs Windows 11 Pro x64 通过
backend/domain/integration/document tests Windows 11 Pro x64 通过
真实 JDT/JDK/JUnit main、单方法、rerun 和安全拒绝 action Windows 11 Pro x64 通过
scripts/run/actions.mjs 真实工具 action(证据:.artifacts/run/evidence.json) Windows 11 Pro x64 通过;覆盖当前文件、精确单函数/测试、陈旧版本、保存失败、声明移除、rerun 和含中文空格路径
scripts/run/visual.mjs Viva 无头截图 Windows 11 Pro x64 通过;截图已检查并嵌入本 PR

未能执行的检查和原因:

  • macOS 原生窗口、其他架构和完整 CI 尚未在本机执行;功能矩阵保持 pending。
  • .artifacts/test-stability HTML/JUnit、最终 package/manifest/store 门禁尚未生成,留给 CI/维护者验收。
  • actionlint 当前版本不认识仓库既有的 GitHub runner 标签(Go 的 windows-11-arm、Java 的 macos-26),未因工具限制修改工作流。
  • Java scripts/package/*.test.mjs 中的 Linux ELF executable-bit 检查在 Windows 上无法执行,留给 Linux CI;macOS 原生窗口仍 pending。

提交前确认 / Final checks

  • 分支从最新的 main 创建;目标分支:main
  • 以 Draft 提交,本地验证通过后再由维护者决定是否标记 ready。
  • 没有无关改动,没有提交 target/、dist/、.artifacts/ 临时产物、凭据、个人路径或未脱敏日志;截图为本仓库固定 fixture 的验收证据。
  • 本次构建、测试或预览启动的新增应用和子进程已清理;保留用户原有 Lithe/Go/environment 进程不在本轮清理范围。

@xiaoyumuxi
xiaoyumuxi marked this pull request as ready for review November 29, 2026 23:19
@xiaoyumuxi
xiaoyumuxi merged commit 9762704 into main Nov 29, 2026
10 of 14 checks passed

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 4 potential issues.

1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

Comment thread backend/src/run.rs
.pointer("/document/path")
.and_then(Value::as_str)
.filter(|path| !path.is_empty())
.filter(|path| safe_document_path(path))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Java run actions reject host paths

When Viva opens a Java file, collect_actions_function rejects the absolute path Viva sends. Neither the gutter nor the current-file toolbar gets a Java Run or Debug action.

Learn more

The pinned Viva host passes the editor's native path through collectEditorActions and CollectEditorActions without converting it to a relative path. Its documents/getSnapshot response uses a different representation: summarize calls RelativePath to return a slash-separated workspace-relative path. Both representations reach collect_actions_function, but the new filter only accepts the latter. The integration host stub sends a relative path from the start, so it misses the desktop path.

Example: Viva passes /work/shop/src/App.java during gutter collection. The backend rejects it before asking JDT about main, even though the same document's snapshot reports src/App.java.

Recommended fix: Normalize the editor collection path to a verified workspace-relative identity before building the action. For native absolute paths, verify containment in the current workspace rather than accepting arbitrary absolute paths; retain relative-path validation and use the normalized identity for snapshot and rerun comparisons. Exercise both host path formats in the integration test.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

"signatureRequirement": "none"
},
"permissions": ["backend.launch", "runtimes.install", "ui.contribute", "documents.contentProvider", "documents.read", "editor.actions", "languageServer.launch", "languageServer.request", "project.generate", "debug.launch", "debug.attach", "debug.start", "run.start", "window.messages", "workspace.metadata"],
"permissions": ["backend.launch", "runtimes.install", "ui.contribute", "documents.contentProvider", "documents.read", "documents.save", "editor.actions", "languageServer.launch", "languageServer.request", "project.generate", "debug.launch", "debug.attach", "debug.start", "run.start", "window.messages", "workspace.metadata"],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 Save permission blocks plugin releases

documents.save is absent from the pinned manifest schema. The contract check rejects the package declaration in both CI and release validation.

Learn more

The SDK transport revision and the manifest schema revision are pinned separately. The SDK verification entry point also runs manifest validation, which loads checksum-pinned schemas from the contract lock. The locked schema's permission enum does not include documents.save, even though the newer Core used by the run-action host does. Both PR CI and release CI invoke that validator.

Example: Validation rejects permissions[6] because its value is documents.save, preventing the release workflow from passing its required test job.

Recommended fix: Move the contract pin and schema hashes to a reviewed Core revision that supports documents.save. Verify the manifest and translations against that revision and document the minimum compatible host. Keep the SDK transport revision independent if its existing request method works.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread backend/src/run.rs
Comment on lines +854 to +860
let documents = context.host().documents().list(reference)?;
let document = documents["documents"]
.as_array()
.into_iter()
.flatten()
.find(|document| document["path"] == params["path"])
.ok_or_else(invalid_target)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Rerun fails after closing source

After the user closes the source tab, rerun_function cannot find the file in the host’s open-document list. The Run panel’s Rerun button fails even though the source is saved and unchanged.

Learn more

In the pinned Viva host, rerunRun saves the project's open documents and forwards the data retained by the finished Run tab. Closing the source editor does not clear that data. The host's Documents implementation enumerates open tabs only. The new lookup therefore refuses a closed file before asking JDT whether the target still exists. The launch request already retains the workspace-relative target path.

Example: Run App.main(), close App.java, and press Rerun in the finished Run tab. The saved main still exists, but the backend refuses the run until the file is reopened.

Recommended fix: Keep the snapshot/versioned-save flow for open files. For a closed file, validate that the stored path identifies an existing file inside the current workspace and ask JDT to revalidate the saved declaration before starting. Cover Rerun with documents/list returning no matching tab.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment thread backend/src/run.rs
Comment on lines +817 to +819
let snapshot = host
.documents()
.get_snapshot(reference, json!({"documentID": params["documentID"]}))?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Large Java files cannot run

run_action_function requests a full snapshot even though it only needs the document path and version. Viva can collect actions for larger files but rejects snapshots over 128 KiB, so those actions never launch.

Learn more

The pinned Viva host sets EditorHost.ActionSourceBytes to 1 MiB for editor action collection, but handleDocumentsSnapshot delegates to Snapshot with a 128 KiB limit. The click only compares metadata from the snapshot, and action collection only reads the document path before asking JDT for declarations. A large document is therefore rejected before saving or launching, even if it is already clean.

Example: With action paths normalized, a 150 KiB Java file with a valid main can show a Run action. Clicking it fails with the snapshot size error; saving or reopening the file does not shrink it.

Recommended fix: Match the document ID against metadata from documents/list, check the path and revision, then revalidate the declaration and retain the expected-version save. Test a document above the snapshot limit but below the collection limit.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@1lck 1lck mentioned this pull request Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Run the current file and an individual function or test

1 participant